package jwdt.web.action;

import jwdt.xadmin.info.bean.TType;

import com.ezerg.db.Jdb;
import com.ezerg.db.ext.PageUtil;
import com.ezerg.web.Form;
import com.ezerg.web.Module;
import com.ezerg.web.Page;

public class SearchAction extends BaseAction {
	
	public Page execute(Form f, Module m) throws Exception{
		//
		int page = f.getInt("page", 1);
		int pageSize = f.getInt("pageSize", 20);
		int typeid = f.getInt("id",0,true);
		TType type = new TType();
		type.setName("查询结果");
		f.add("type", type);
		//相关
		f.add("about", Jdb.get().query(super.select_news+" where checked=1 and typeid= "+ typeid + super.order_news+" limit 8"));
		//滚动图片
		f.add("imgs", Jdb.get().query(super.select_news+" where goodnews=1 and checked=1 and picnews=1 "+super.order_news+" limit 5"));
		//最新
		f.add("qzzx", Jdb.get().query(super.select_news+" where checked=1 "+super.order_news+" limit 8"));
		//
		int rows = 4;
		super.getListByTypeid(typeid, "objs", rows, f);//
		super.getListByTypeid2(typeid, 0, "objs0", rows, f);//
		super.getListByTypeid2(typeid, 1, "objs1", rows, f);//
		super.getListByTypeid2(typeid, 2, "objs2", rows, f);//
		super.getListByTypeid2(typeid, 3, "objs3", rows, f);//
		super.getListByTypeid2(typeid, 4, "objs4", rows, f);//
		//
		String where = " where checked=1 ";
		String key = f.getString("key");
		if(!"".equals(key)) {
			where += " and title like'%"+key+"%'";
		}
		String sql = super.select_news + where + super.order_news;
		PageUtil pu = new PageUtil("select count(*) from t_news "+where, sql, page, pageSize);
		f.add("pager", pu.setUrl(m.getFullPath() + ".htm").setParams(f.buildQueryMap()));
		return m.findPage("/list");
	}
}
